package de.bensoft.jrail.business.entity;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

@NamedQueries({
	@NamedQuery(name=Locomotive.GET_ALL, query="select l from Locomotive l")
})

@Entity
public class Locomotive implements Serializable {
	
	// Globals
	public static final Long[]  AVAILABLE_SPEEDSTEPS = new Long[] { 28l, 128l };
	
	private static final long serialVersionUID = 1L;
	public static final String GET_ALL = "Locomotive.getall";
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	private String name;
	
	private Long address;
	
	private Long speedSteps;
	
	public Locomotive() {
		name = "New Loco";
			
	}
	
	@Override
	public String toString() {
		String r =  name;
		if(address != null)	
			r += " (" + address.toString() + ")";
		return r;
	}
	
	// **********************************************
	// Generated stuff
	// **********************************************
	
	

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Long getAddress() {
		return address;
	}

	public void setAddress(Long address) {
		this.address = address;
	}

	public Long getSpeedSteps() {
		return speedSteps;
	}

	public void setSpeedSteps(Long speedSteps) {
		this.speedSteps = speedSteps;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((address == null) ? 0 : address.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((speedSteps == null) ? 0 : speedSteps.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Locomotive other = (Locomotive) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (speedSteps == null) {
			if (other.speedSteps != null)
				return false;
		} else if (!speedSteps.equals(other.speedSteps))
			return false;
		return true;
	}

	


}
